package org.springsource.domain;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonManagedReference;

@Entity
@Table(name = "Category")
public class Category implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -1580890247840501217L;
	private Long categoryId;
	private String name;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(nullable = false,unique = true)
	public Long getCategoryId() {
		return categoryId;
	}
	public void setCategoryId(Long categoryId) {
		this.categoryId = categoryId;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@JsonManagedReference
	@OneToMany(fetch = FetchType.EAGER, mappedBy = "pk.category")
	public Set<AccountCategory> getAccountCategories() {
		return accountCategories;
	}
	public void setAccountCategories(Set<AccountCategory> accountCategories) {
		this.accountCategories = accountCategories;
	}

	
	private Set<AccountCategory> accountCategories = new HashSet<AccountCategory>(0);
}
